package com.bocloud.cmp.entity.resource;

import java.util.Date;
import java.util.List;

import org.springframework.format.annotation.DateTimeFormat;

import com.bocloud.cmp.model.NetcardOperation;
import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * 云主机实体类
 * 
 * @author DZG
 * @since V1.0 2016年9月12日
 */
@Table("cloud_server")
public class CloudServer extends GenericEntity {

    @PK(value = PKStrategy.AUTO)
    private Long id; // ID
    @Column("account")
    private String account; // 账号
    @Column("password")
    private String password; // 密码
    @Column("cpu")
    private Integer cpu; // CPU核数
    @Column("memory")
    private Integer memory; // 内存大小
    @Column("disk")
    private Integer disk; // 磁盘容量
    @Column("private_ips")
    private String privateIps; // 私有IP
    @Column("public_ips")
    private String publicIps;// 公有IP
    @Column("manager_port")
    private Integer managerPort; // 管理端口
    @Column("vendor_id")
    private Long vendorId; // 云供应商Id
    @IgnoreAll
    private String vendorName; // 云供应商名称
    @IgnoreAll
    private String vendorType; // 云供应商名称
    @Column("region")
    private Long region;// 供应商区域ID
    @IgnoreAll
    private String regionName; // 供应商区域名称
    @Column("image_id")
    private String imageId; // 镜像ID
    @Column("flavor_id")
    private String flavorId; // 配置ID
    @Column("network_id")
    private String networkId;// 网络ID
    @Column("instance_id")
    private String instanceId;// 云主机ID
    @Column("uuid")
    private String uuid; // UUID
    @Column("subnet_id")
    private String subnetId;
    @Column("zone")
    private String zone; // 区域
    @Column("router_id")
    private String routerId;// 路由ID
    @Column("security_group_id")
    private String securityGroupId;
    @Column("request_id")
    private String requestId;
    @Column("manager_ip")
    private String managerIp;
    @Column("expired_time")
    @JsonSerialize(using = DateSerializer.class)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date expiredTime;// 过期时间
    @Column("is_template")
    private Boolean isTemplate;// 是否是模板
    @Column("region_id")
    private String regionId;// 区域ID
    @Column("internet_charge_type")
    private String internetChargeType;// 网络计费类型
    @Column("internet_max_bandwidthIn")
    private Integer internetMaxBandwidthIn;// 公网入带宽最大值
    @Column("internet_max_bandwidthOut")
    private Integer internetMaxBandwidthOut;// 公网出带宽最大值
    @Column("instance_charge_type")
    private String instanceChargeType;// 实例付费类型
    @Column("instance_network_type")
    private String instanceNetworkType;// 实例的网络类型
    @Column("instance_type")
    private String instanceType;// 实例类型
    @Column("system_disk_category")
    private String systemDiskCategory;// 系统盘的类型
    @Column("system_disk_size")
    private Integer systemDiskSize;// 系统盘的大小
    @Column("data_disk")
    private String dataDisk;// 数据盘
    @Column("host_id")
    private Long hostId;// 宿主机id
    @Column("template_id")
    private Long templateId;// 数据盘
    @IgnoreAll
    private String template;// 模板名称
    @IgnoreAll
    private String datastore;
    @IgnoreAll
    private List<Snapshot> snapshots;
    @IgnoreAll
    private Integer snapshotCount;// 快照数量
    @IgnoreAll
    private String clusterName;
    @Column("tools_installed")
    private Boolean toolsInstalled;
    @Column("tools_running")
    private Boolean toolsRunning;
    @IgnoreAll
    private Integer extendDisk;
    @Column("host_name")
    private String hostName;
    @Column("datastores")
    private String datastores;
    @IgnoreAll
    private List<String> stores;
    @IgnoreAll
    private List<String> networks;
    @IgnoreAll
    private List<NetworkCard> netcards;
    @IgnoreAll
    private List<NetcardOperation> operations;
    @IgnoreAll
    private List<ServerIp> serverIps;

    /**
     * @return the serverIps
     */
    public List<ServerIp> getServerIps() {
        return serverIps;
    }

    /**
     * @param serverIps
     *            the serverIps to set
     */
    public void setServerIps(List<ServerIp> serverIps) {
        this.serverIps = serverIps;
    }

    /**
     * @return the hostName
     */
    public String getHostName() {
        return hostName;
    }

    /**
     * @param hostName
     *            the hostName to set
     */
    public void setHostName(String hostName) {
        this.hostName = hostName;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the account
     */
    public String getAccount() {
        return account;
    }

    /**
     * @param account
     *            the account to set
     */
    public void setAccount(String account) {
        this.account = account;
    }

    /**
     * @return the password
     */
    public String getPassword() {
        return password;
    }

    /**
     * @param password
     *            the password to set
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * @return the cpu
     */
    public Integer getCpu() {
        return cpu;
    }

    /**
     * @param cpu
     *            the cpu to set
     */
    public void setCpu(Integer cpu) {
        this.cpu = cpu;
    }

    /**
     * @return the memory
     */
    public Integer getMemory() {
        return memory;
    }

    /**
     * @param memory
     *            the memory to set
     */
    public void setMemory(Integer memory) {
        this.memory = memory;
    }

    /**
     * @return the disk
     */
    public Integer getDisk() {
        return disk;
    }

    /**
     * @param disk
     *            the disk to set
     */
    public void setDisk(Integer disk) {
        this.disk = disk;
    }

    /**
     * @return the privateIps
     */
    public String getPrivateIps() {
        return privateIps;
    }

    /**
     * @param privateIps
     *            the privateIps to set
     */
    public void setPrivateIps(String privateIps) {
        this.privateIps = privateIps;
    }

    /**
     * @return the publicIps
     */
    public String getPublicIps() {
        return publicIps;
    }

    /**
     * @param publicIps
     *            the publicIps to set
     */
    public void setPublicIps(String publicIps) {
        this.publicIps = publicIps;
    }

    /**
     * @return the managerPort
     */
    public Integer getManagerPort() {
        return managerPort;
    }

    /**
     * @param managerPort
     *            the managerPort to set
     */
    public void setManagerPort(Integer managerPort) {
        this.managerPort = managerPort;
    }

    /**
     * @return the vendorId
     */
    public Long getVendorId() {
        return vendorId;
    }

    /**
     * @param vendorId
     *            the vendorId to set
     */
    public void setVendorId(Long vendorId) {
        this.vendorId = vendorId;
    }

    /**
     * @return the vendorName
     */
    public String getVendorName() {
        return vendorName;
    }

    /**
     * @param vendorName
     *            the vendorName to set
     */
    public void setVendorName(String vendorName) {
        this.vendorName = vendorName;
    }

    /**
     * @return the vendorType
     */
    public String getVendorType() {
        return vendorType;
    }

    /**
     * @param vendorType
     *            the vendorType to set
     */
    public void setVendorType(String vendorType) {
        this.vendorType = vendorType;
    }

    /**
     * @return the region
     */
    public Long getRegion() {
        return region;
    }

    /**
     * @param region
     *            the region to set
     */
    public void setRegion(Long region) {
        this.region = region;
    }

    /**
     * @return the regionName
     */
    public String getRegionName() {
        return regionName;
    }

    /**
     * @param regionName
     *            the regionName to set
     */
    public void setRegionName(String regionName) {
        this.regionName = regionName;
    }

    /**
     * @return the imageId
     */
    public String getImageId() {
        return imageId;
    }

    /**
     * @param imageId
     *            the imageId to set
     */
    public void setImageId(String imageId) {
        this.imageId = imageId;
    }

    /**
     * @return the flavorId
     */
    public String getFlavorId() {
        return flavorId;
    }

    /**
     * @param flavorId
     *            the flavorId to set
     */
    public void setFlavorId(String flavorId) {
        this.flavorId = flavorId;
    }

    /**
     * @return the networkId
     */
    public String getNetworkId() {
        return networkId;
    }

    /**
     * @param networkId
     *            the networkId to set
     */
    public void setNetworkId(String networkId) {
        this.networkId = networkId;
    }

    /**
     * @return the instanceId
     */
    public String getInstanceId() {
        return instanceId;
    }

    /**
     * @param instanceId
     *            the instanceId to set
     */
    public void setInstanceId(String instanceId) {
        this.instanceId = instanceId;
    }

    /**
     * @return the uuid
     */
    public String getUuid() {
        return uuid;
    }

    /**
     * @param uuid
     *            the uuid to set
     */
    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    /**
     * @return the subnetId
     */
    public String getSubnetId() {
        return subnetId;
    }

    /**
     * @param subnetId
     *            the subnetId to set
     */
    public void setSubnetId(String subnetId) {
        this.subnetId = subnetId;
    }

    /**
     * @return the zone
     */
    public String getZone() {
        return zone;
    }

    /**
     * @param zone
     *            the zone to set
     */
    public void setZone(String zone) {
        this.zone = zone;
    }

    /**
     * @return the routerId
     */
    public String getRouterId() {
        return routerId;
    }

    /**
     * @param routerId
     *            the routerId to set
     */
    public void setRouterId(String routerId) {
        this.routerId = routerId;
    }

    /**
     * @return the securityGroupId
     */
    public String getSecurityGroupId() {
        return securityGroupId;
    }

    /**
     * @param securityGroupId
     *            the securityGroupId to set
     */
    public void setSecurityGroupId(String securityGroupId) {
        this.securityGroupId = securityGroupId;
    }

    /**
     * @return the requestId
     */
    public String getRequestId() {
        return requestId;
    }

    /**
     * @param requestId
     *            the requestId to set
     */
    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    /**
     * @return the managerIp
     */
    public String getManagerIp() {
        return managerIp;
    }

    /**
     * @param managerIp
     *            the managerIp to set
     */
    public void setManagerIp(String managerIp) {
        this.managerIp = managerIp;
    }

    /**
     * @return the expiredTime
     */
    public Date getExpiredTime() {
        return expiredTime;
    }

    /**
     * @param expiredTime
     *            the expiredTime to set
     */
    public void setExpiredTime(Date expiredTime) {
        this.expiredTime = expiredTime;
    }

    /**
     * @return the isTemplate
     */
    public Boolean getIsTemplate() {
        return isTemplate;
    }

    /**
     * @param isTemplate
     *            the isTemplate to set
     */
    public void setIsTemplate(Boolean isTemplate) {
        this.isTemplate = isTemplate;
    }

    /**
     * @return the regionId
     */
    public String getRegionId() {
        return regionId;
    }

    /**
     * @param regionId
     *            the regionId to set
     */
    public void setRegionId(String regionId) {
        this.regionId = regionId;
    }

    /**
     * @return the internetChargeType
     */
    public String getInternetChargeType() {
        return internetChargeType;
    }

    /**
     * @param internetChargeType
     *            the internetChargeType to set
     */
    public void setInternetChargeType(String internetChargeType) {
        this.internetChargeType = internetChargeType;
    }

    /**
     * @return the internetMaxBandwidthIn
     */
    public Integer getInternetMaxBandwidthIn() {
        return internetMaxBandwidthIn;
    }

    /**
     * @param internetMaxBandwidthIn
     *            the internetMaxBandwidthIn to set
     */
    public void setInternetMaxBandwidthIn(Integer internetMaxBandwidthIn) {
        this.internetMaxBandwidthIn = internetMaxBandwidthIn;
    }

    /**
     * @return the internetMaxBandwidthOut
     */
    public Integer getInternetMaxBandwidthOut() {
        return internetMaxBandwidthOut;
    }

    /**
     * @param internetMaxBandwidthOut
     *            the internetMaxBandwidthOut to set
     */
    public void setInternetMaxBandwidthOut(Integer internetMaxBandwidthOut) {
        this.internetMaxBandwidthOut = internetMaxBandwidthOut;
    }

    /**
     * @return the instanceChargeType
     */
    public String getInstanceChargeType() {
        return instanceChargeType;
    }

    /**
     * @param instanceChargeType
     *            the instanceChargeType to set
     */
    public void setInstanceChargeType(String instanceChargeType) {
        this.instanceChargeType = instanceChargeType;
    }

    /**
     * @return the instanceNetworkType
     */
    public String getInstanceNetworkType() {
        return instanceNetworkType;
    }

    /**
     * @param instanceNetworkType
     *            the instanceNetworkType to set
     */
    public void setInstanceNetworkType(String instanceNetworkType) {
        this.instanceNetworkType = instanceNetworkType;
    }

    /**
     * @return the instanceType
     */
    public String getInstanceType() {
        return instanceType;
    }

    /**
     * @param instanceType
     *            the instanceType to set
     */
    public void setInstanceType(String instanceType) {
        this.instanceType = instanceType;
    }

    /**
     * @return the systemDiskCategory
     */
    public String getSystemDiskCategory() {
        return systemDiskCategory;
    }

    /**
     * @param systemDiskCategory
     *            the systemDiskCategory to set
     */
    public void setSystemDiskCategory(String systemDiskCategory) {
        this.systemDiskCategory = systemDiskCategory;
    }

    /**
     * @return the systemDiskSize
     */
    public Integer getSystemDiskSize() {
        return systemDiskSize;
    }

    /**
     * @param systemDiskSize
     *            the systemDiskSize to set
     */
    public void setSystemDiskSize(Integer systemDiskSize) {
        this.systemDiskSize = systemDiskSize;
    }

    /**
     * @return the dataDisk
     */
    public String getDataDisk() {
        return dataDisk;
    }

    /**
     * @param dataDisk
     *            the dataDisk to set
     */
    public void setDataDisk(String dataDisk) {
        this.dataDisk = dataDisk;
    }

    /**
     * @return the hostId
     */
    public Long getHostId() {
        return hostId;
    }

    /**
     * @param hostId
     *            the hostId to set
     */
    public void setHostId(Long hostId) {
        this.hostId = hostId;
    }

    /**
     * @return the templateId
     */
    public Long getTemplateId() {
        return templateId;
    }

    /**
     * @param templateId
     *            the templateId to set
     */
    public void setTemplateId(Long templateId) {
        this.templateId = templateId;
    }

    /**
     * @return the template
     */
    public String getTemplate() {
        return template;
    }

    /**
     * @param template
     *            the template to set
     */
    public void setTemplate(String template) {
        this.template = template;
    }

    /**
     * @return the datastore
     */
    public String getDatastore() {
        return datastore;
    }

    /**
     * @param datastore
     *            the datastore to set
     */
    public void setDatastore(String datastore) {
        this.datastore = datastore;
    }

    /**
     * @return the snapshots
     */
    public List<Snapshot> getSnapshots() {
        return snapshots;
    }

    /**
     * @param snapshots
     *            the snapshots to set
     */
    public void setSnapshots(List<Snapshot> snapshots) {
        this.snapshots = snapshots;
    }

    /**
     * @return the snapshotCount
     */
    public Integer getSnapshotCount() {
        return snapshotCount;
    }

    /**
     * @param snapshotCount
     *            the snapshotCount to set
     */
    public void setSnapshotCount(Integer snapshotCount) {
        this.snapshotCount = snapshotCount;
    }

    /**
     * @return the clusterName
     */
    public String getClusterName() {
        return clusterName;
    }

    /**
     * @param clusterName
     *            the clusterName to set
     */
    public void setClusterName(String clusterName) {
        this.clusterName = clusterName;
    }

    /**
     * @return the toolsInstalled
     */
    public Boolean getToolsInstalled() {
        return toolsInstalled;
    }

    /**
     * @param toolsInstalled
     *            the toolsInstalled to set
     */
    public void setToolsInstalled(Boolean toolsInstalled) {
        this.toolsInstalled = toolsInstalled;
    }

    /**
     * @return the toolsRunning
     */
    public Boolean getToolsRunning() {
        return toolsRunning;
    }

    /**
     * @param toolsRunning
     *            the toolsRunning to set
     */
    public void setToolsRunning(Boolean toolsRunning) {
        this.toolsRunning = toolsRunning;
    }

    /**
     * @return the extendDisk
     */
    public Integer getExtendDisk() {
        return extendDisk;
    }

    /**
     * @param extendDisk
     *            the extendDisk to set
     */
    public void setExtendDisk(Integer extendDisk) {
        this.extendDisk = extendDisk;
    }

    /**
     * @return the datastores
     */
    public String getDatastores() {
        return datastores;
    }

    /**
     * @param datastores
     *            the datastores to set
     */
    public void setDatastores(String datastores) {
        this.datastores = datastores;
    }

    /**
     * @return the stores
     */
    public List<String> getStores() {
        return stores;
    }

    /**
     * @param stores
     *            the stores to set
     */
    public void setStores(List<String> stores) {
        this.stores = stores;
    }

    /**
     * @return the networks
     */
    public List<String> getNetworks() {
        return networks;
    }

    /**
     * @param networks
     *            the networks to set
     */
    public void setNetworks(List<String> networks) {
        this.networks = networks;
    }

    /**
     * @return the netcards
     */
    public List<NetworkCard> getNetcards() {
        return netcards;
    }

    /**
     * @param netcards
     *            the netcards to set
     */
    public void setNetcards(List<NetworkCard> netcards) {
        this.netcards = netcards;
    }

    /**
     * @return the operations
     */
    public List<NetcardOperation> getOperations() {
        return operations;
    }

    /**
     * @param operations
     *            the operations to set
     */
    public void setOperations(List<NetcardOperation> operations) {
        this.operations = operations;
    }

    public void preSave(Long createrId, Long menderId, Long vendorId, Long hostId, Long templateId) {
        this.setCreaterId(createrId);
        this.setMenderId(menderId);
        this.setVendorId(vendorId);
        this.setHostId(hostId);
        this.setTemplateId(templateId);
    }

}
